<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>飞行试验子信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/systemStatic/style/admin.css">
    <link rel="stylesheet" href="/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="/css/public.css">
    <script type="text/javascript">
        var __ctx = "";
    </script>
</head>
<body>

<div style="margin: 10px">
    <table id="wQbdFlighttestChildTable" lay-filter="wQbdFlighttestChildTable"></table>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdFlighttestChildHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <a class="layui-btn layui-btn-sm" lay-event="add">
                <i class="layui-icon layui-icon-add-1"></i>
                <span>新增</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="delete">
                <i class="layui-icon layui-icon-delete"></i>
                <span>删除</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="export">
                <i class="layui-icon layui-icon-export"></i>
                <span>导出</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="import">
                <i class="layui-icon layui-icon-download-circle"></i>
                <span>导入</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="query">
                <i class="layui-icon layui-icon-search"></i>
                <span>查询</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="clears">
                <i class="layui-icon layui-icon-refresh"></i>
                <span>重置</span>
            </a>
        </div>
        <form class="layui-form" action="" lay-filter="wQbdFlighttestChildQueryForm" style="margin-right: 30px;">
            <div class="layui-row" style="margin-top: 10px;">
                <div class="selch table-top-filter">
                        <div class="table-filter-alone">
                                <label class="layui-form-label">主键</label>
                                <input type="text" class="layui-input filter-value" name="Q_id_SL" placeholder="请输入"/>
                        </div>
                        <div class="table-filter-alone">
                                <label class="layui-form-label">单位名称</label>
                                <input type="text" class="layui-input filter-value" name="Q_companyName_SL" placeholder="请输入"/>
                        </div>
                        <div class="table-filter-alone">
                                <label class="layui-form-label">奖励总人数</label>
                                <input type="text" class="layui-input filter-value" name="Q_totalNumberOfAwards_SL" placeholder="请输入"/>
                        </div>
                        <div class="table-filter-alone">
                                <label class="layui-form-label">金额</label>
                                <input type="text" class="layui-input filter-value" name="Q_sumOfMoney_SL" placeholder="请输入"/>
                        </div>
                        <div class="table-filter-alone">
                                <label class="layui-form-label">详细情况</label>
                                <input type="text" class="layui-input filter-value" name="Q_details_SL" placeholder="请输入"/>
                        </div>
                        <div class="table-filter-alone">
                                <label class="layui-form-label">排序</label>
                                <input type="text" class="layui-input filter-value" name="Q_sort_L" placeholder="请输入"/>
                        </div>
                        <div class="table-filter-alone">
                                <label class="layui-form-label">外键</label>
                                <input type="text" class="layui-input filter-value" name="Q_refid_SL" placeholder="请输入"/>
                        </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdFlighttestChildRightToolsBar">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs" lay-event="particulars">详情</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    {{# if(d.runId == '' ){ }}
    <a class="layui-btn layui-btn-xs" lay-event="run">启动</a>
    {{# } }}
</script>
<script src="/public/component.js" type="text/javascript"></script>
<script src="/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','table', 'setter', 'form', 'common','totalFilter','commons','jquery','layer'], function () {
        var table = layui.table;
        var setter = layui.setter;
        var form = layui.form;
        var common = layui.common;
        var commons = layui.commons;
        var $ = layui.jquery;
        var layer = layui.layer;
        var totalFilter = layui.totalFilter;
        common.tableSort('wQbdFlighttestChildTable');

        var tableH=commons.tabHeight();

        //第一个实例
        table.render({
            elem: '#wQbdFlighttestChildTable'
            ,height:tableH
            ,url: serverPath.basePath + '/qbdms/wQbdFlighttestChild/list'
            ,page: true //开启分页
            ,toolbar: '#wQbdFlighttestChildHeaderToolsBar'
            ,method: 'post'
            ,autoSort: false //是否排序
            ,cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}
                ,{field: 'id', title: '主键',sort:true, sortname: 'id'}
                ,{field: 'companyName', title: '单位名称',sort:true, sortname: 'company_name'}
                ,{field: 'totalNumberOfAwards', title: '奖励总人数',sort:true, sortname: 'total_number_of_awards'}
                ,{field: 'sumOfMoney', title: '金额',sort:true, sortname: 'sum_of_money'}
                ,{field: 'details', title: '详细情况',sort:true, sortname: 'details'}
                ,{field: 'sort', title: '排序',sort:true, sortname: 'sort'}
                ,{field: 'refid', title: '外键',sort:true, sortname: 'refid'}
                ,{
                    fixed: 'right',
                    title: '管理',
                    toolbar: '#wQbdFlighttestChildRightToolsBar'
                }
            ]],done:function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
            }
        });

        totalFilter.init('wQbdFlighttestChildTable');
        dateReflash()
        function dateReflash() {
            commons.reflashDate({startName:'.start_time1',endName:'.end_time1'});
            commons.reflashDate({startName:'.start_time0',endName:'.end_time0'});
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdFlighttestChildTable","wQbdFlighttestChildQueryForm",{where:{}},isClear);
        }

        table.on('toolbar(wQbdFlighttestChildTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = serverPath.basePath + "/qbdms/wQbdFlighttestChild/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    delFun(data,array);
                    break;
                case 'export':
                    if (data.length == 0) {
                        layer.confirm('还没有选择，是否导出全部？', {
                            btn: ['确定', '取消'] //按钮
                        }, function (index) {
                            layer.close(index);
                            var url = serverPath.systemPath + '/qbdms/wQbdFlighttestChild/exportData';
                            $("form[lay-filter='wQbdFlighttestChildQueryForm']").find(".filter-value").each(function(i,value) {
                                if(i ==0){
                                    url += "?"+this.name+"="+this.value
                                }else{
                                    url += "&"+this.name+"="+this.value
                                }
                            });
                            window.location.href = url;
                        });
                    } else {
                        layer.confirm('确定导出吗？', {
                            btn: ['是', '否'] //按钮
                        }, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = serverPath.systemPath + '/qbdms/wQbdFlighttestChild/exportData?id=' + ids;
                            window.location.href = url;
                        });
                    }
                    break;
                case "import":
                    layer.open({
                        type: 2,
                        title: "导入",
                        shade: 0.3,
                        area: ['400px', '300px'],
                        content: serverPath.systemPath + "/qbdms/wQbdFlighttestChild/view/import"
                        ,end:function () {
                            table.reload('wQbdFlighttestChildTable', {
                                page: {
                                    curr: 1
                                }
                            });
                            totalFilter.init('wQbdFlighttestChildTable');
                            dateReflash();
                        }
                    });
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;

            };
        });

        table.on('tool(wQbdFlighttestChildTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":
                    window.location.href = serverPath.basePath + '/qbdms/wQbdFlighttestChild/view/add?id='+data.id+"&runId="+data.runId
                    break;
                case "particulars":
                    window.location.href = serverPath.basePath + '/qbdms/wQbdFlighttestChild/view/particulars?id='+data.id;
                    break;
                case "del":
                    delFun(data,data.id);
                    break;
                case "run":
                    layer.confirm("确定启动该条信息吗?",{title: false,skin: 'confirm-class'},function (index) {
                        layer.close(index);
                        var nowData = {"id": data.id,"companyName": data.companyName,"totalNumberOfAwards": data.totalNumberOfAwards,"sumOfMoney": data.sumOfMoney,"details": data.details,"sort": data.sort,"refid": data.refid};
                        $.ajax({
                            url: serverPath.basePath + "/qbdms/wQbdFlighttestChild/run",
                            type: "post",
                            data: JSON.stringify(nowData),
                            dataType: 'json',
                            contentType : 'application/json',
                            success: function (data) {
                                layer.alert(data.msg);
                                //执行重载
                                reflashQuery(true);
                                dateReflash();
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                layer.alert(data.msg);
                                //执行重载
                                reflashQuery(true);
                                dateReflash();
                            }
                        })
                    })
                    break;
            }
        });

        function delFun(data,id) {
            if (data.length === 0) {
                layer.msg('请先选择一行数据!',{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm('确定删除当前数据吗?',{title: false,skin: 'confirm-class'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.basePath + "/qbdms/wQbdFlighttestChild/del",
                        type: "post",
                        data: {id:id},
                        dataType: 'json',
                        success: function (data) {
                            layer.alert(data.msg);
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert(data.msg);
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            dateReflash();
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wQbdFlighttestChildTable",{show:window.Initialization});
    });
</script>
</body>
</html>